package 两数之和;

class Solution {
    public int[] twoSum(int[] price, int target) {
        int left = 0;
        int right = price.length - 1;
        int[] ret = new int[2];
        while(left < right){
            int sum = price[left] + price[right];
            if(sum > target){
                right--;
            }else if(sum < target){
                left++;
            }else{
                ret[0] = price[left];
                ret[1] = price[right];
                break;
            }
        }
        return ret;
    }
}